﻿using KinonekoSoftware.CodariaDB.Documents.Theories.Rarities;

namespace KinonekoSoftware.Studio.Models.Theories
{
    public class RarityComparer : Comparer<TheoryOfRarityPresenter>
    {

        public override int Compare(TheoryOfRarityPresenter x, TheoryOfRarityPresenter y)
        {
            var xLevel = x?.Level ?? 0;
            var yLevel = y?.Level ?? 0;
            return xLevel - yLevel;
        }
    }
    
    public class TheoryOfRarityPresenter : ObservableObject
    {

        public static TheoryOfRarityPresenter Select(Rarity rarity) => new TheoryOfRarityPresenter
        {
            TargetObject = rarity,
        };

        public void RaiseUpdates()
        {
            RaiseUpdated(nameof(Image));
            RaiseUpdated(nameof(Icon));
            RaiseUpdated(nameof(Intro));
            RaiseUpdated(nameof(Stroke));
            RaiseUpdated(nameof(Level));
            RaiseUpdated(nameof(Name));
            RaiseUpdated(nameof(Foreground));
            RaiseUpdated(nameof(Background));
        }
        
        public required Rarity TargetObject { get; init; }
        
        public string Id => TargetObject.Id;
        
        public string Image
        {
            get => TargetObject.Image;
            set
            {
                TargetObject.Image = value;
                RaiseUpdated();
            }
        }
        
        public string Icon
        {
            get => TargetObject.Icon;
            set
            {
                TargetObject.Icon = value;
                RaiseUpdated();
            }
        }

        public string Name
        {
            get => TargetObject.Name;
            set
            {
                TargetObject.Name = value;
                RaiseUpdated();
            }
        }
        
        

        public string Stroke
        {
            get => TargetObject.Stroke;
            set
            {
                TargetObject.Stroke = value;
                RaiseUpdated();
            }
        }


        public string Intro
        {
            get => TargetObject.Intro;
            set
            {
                TargetObject.Intro = value;
                RaiseUpdated();
            }
        }
        
        
        public int Level
        {
            get => TargetObject.Level;
            set
            {
                TargetObject.Level = value;
                RaiseUpdated();
            }
        }

        public string Foreground
        {
            get => TargetObject.Foreground;
            set
            {
                TargetObject.Foreground = value;
                RaiseUpdated();
            }
        }
        
        public string Background
        {
            get => TargetObject.Background;
            set
            {
                TargetObject.Background = value;
                RaiseUpdated();
            }
        }
    }

}